﻿<Application 
    x:Class="Wulong.Phone.Dianping.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Wulong.Phone.Dianping" 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:i18n="clr-namespace:Wulong.Phone.Dianping.i18n" 
    xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" >

    <!--Application Resources-->
    <Application.Resources>
        <i18n:LocalizedStrings x:Key="ls"/>
        <cal:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <local:AppBootstrapper x:Key="bootstrapper" />

        <Style x:Key="LoadingStyle" 
               TargetType="TextBlock" BasedOn="{StaticResource PhoneTextAccentStyle}">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Left" />
        </Style>
        <Style x:Key="ListSubtitleStyle" 
               TargetType="TextBlock" BasedOn="{StaticResource PhoneTextLargeStyle}">
            <Setter Property="VerticalAlignment" Value="Top" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="TextWrapping" Value="Wrap"/>
            <Setter Property="Margin" Value="12"/>
            <Setter Property="Padding" Value="5"/>
        </Style>
        <Style x:Key="NoBorderBtnStyle" TargetType="Button">
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="Foreground" Value="#4f391e"/>
        </Style>
        <Style x:Key="ListItemBtnStyle" 
               BasedOn="{StaticResource NoBorderBtnStyle}" 
               TargetType="Button">
            <Setter Property="Width" Value="380"/>
            <Setter Property="Padding" Value="0"/>
        </Style>
        <Style x:Key="ListStyle" TargetType="ListBox">
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeExtraLarge}"/>
            <Setter Property="Margin" Value="12,0"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBox">
                        <ScrollViewer x:Name="ScrollViewer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}">
                            <ItemsPresenter/>
                        </ScrollViewer>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="TransitionPageStyle" TargetType="phone:PhoneApplicationPage">
            <Setter Property="toolkit:TransitionService.NavigationInTransition">
                <Setter.Value>
                    <toolkit:NavigationInTransition>
                        <toolkit:NavigationInTransition.Backward>
                            <toolkit:TurnstileTransition Mode="BackwardIn"/>
                        </toolkit:NavigationInTransition.Backward>
                        <toolkit:NavigationInTransition.Forward>
                            <toolkit:TurnstileTransition Mode="ForwardIn"/>
                        </toolkit:NavigationInTransition.Forward>
                    </toolkit:NavigationInTransition>
                </Setter.Value>
            </Setter>
            <Setter Property="toolkit:TransitionService.NavigationOutTransition">
                <Setter.Value>
                    <toolkit:NavigationOutTransition>
                        <toolkit:NavigationOutTransition.Backward>
                            <toolkit:TurnstileTransition Mode="BackwardOut"/>
                        </toolkit:NavigationOutTransition.Backward>
                        <toolkit:NavigationOutTransition.Forward>
                            <toolkit:TurnstileTransition Mode="ForwardOut"/>
                        </toolkit:NavigationOutTransition.Forward>
                    </toolkit:NavigationOutTransition>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="MerchantListBoxStyle" TargetType="ListBox">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBox">
                        <ScrollViewer x:Name="ScrollViewer" 
                                      BorderBrush="{TemplateBinding BorderBrush}" 
                                      BorderThickness="{TemplateBinding BorderThickness}" 
                                      Background="{TemplateBinding Background}" 
                                      Foreground="{TemplateBinding Foreground}" 
                                      Padding="{TemplateBinding Padding}">
                            <StackPanel>
                                <ItemsPresenter/>
                                <Button cal:Message.Attach="[Event Click]=[Action LoadMore()]" 
                                        Content="{Binding Path=Appi18n.LoadMore, Source={StaticResource ls}}" 
                                        BorderBrush="Transparent" 
                                        BorderThickness="0" 
                                        Visibility="{Binding CanLoadMore, Converter={StaticResource BooleanToVisibilityConverter}}"
                                        Margin="12,12,12,48"/>
                            </StackPanel>
                        </ScrollViewer>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <DataTemplate x:Name="CityPickerItemTemplate">
            <StackPanel Orientation="Horizontal">
                <Border Background="LightGreen" Width="36" Height="36" Padding="0">
                    <TextBlock Text="{Binding Shortcut}" 
                               Style="{StaticResource PhoneTextSmallStyle}"
                               VerticalAlignment="Center"/>
                </Border>
                <TextBlock Text="{Binding Name}" 
                           Margin="12,0"
                           Style="{StaticResource PhoneTextNormalStyle}"/>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Name="CityPickerFullModeItemTemplate">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Name}" 
                           Margin="12,0" 
                           Style="{StaticResource PhoneTextLargeStyle}"/>
                <TextBlock Text="{Binding Pinyin}" 
                           Foreground="Green"
                           Style="{StaticResource PhoneTextNormalStyle}"/>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Name="CityPickeHeaderTemplate">
            <TextBlock 
                Text="{Binding Path=Appi18n.Choose_Your_City, Source={StaticResource ls}}"
                Foreground="#4f391e"
                Style="{StaticResource PhoneTextNormalStyle}"
                />
        </DataTemplate>
        <DataTemplate x:Name="MerchantListItemTemplate">
            <StackPanel Orientation="Horizontal">
                <Image Source="{Binding ImageUrl}"
                       Width="120"
                       Margin="12,0"
                       />
                <StackPanel>
                    <TextBlock Text="{Binding Name}"
                                       Foreground="#4f391e"
                                       Style="{StaticResource PhoneTextLargeStyle}"/>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="{Binding OverallRating}"/>
                        <TextBlock Text="{Binding AvgPrice}"
                                       Foreground="Gainsboro"
                                       Style="{StaticResource PhoneTextNormalStyle}"/>
                        <Image Source="/Images/Membership.png"
                                       Visibility="{Binding IsMember, 
                                    Converter={StaticResource BooleanToVisibilityConverter}}"/>
                        <Image Source="/Images/Promotion.png"
                                       Visibility="{Binding HasPromotion, 
                                    Converter={StaticResource BooleanToVisibilityConverter}}"/>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal">
                        <Border Background="CadetBlue" 
                                        Margin="12,0"
                                        >
                            <TextBlock Text="{Binding Circle}"
                                        Style="{StaticResource PhoneTextSmallStyle}"
                                        Foreground="White"/>
                        </Border>
                        <Border Background="CadetBlue" 
                                        Margin="12,0">
                            <TextBlock Text="{Binding SubCategory}"
                                        Style="{StaticResource PhoneTextSmallStyle}"
                                        Foreground="White"/>
                        </Border>
                    </StackPanel>
                </StackPanel>
            </StackPanel>
        </DataTemplate>
    </Application.Resources>

</Application>